import requests
import time

print(time.strftime('开始时间:%Y-%m-%d %H:%M:%S'))
try:
    html_str = requests.get('https://baidu.com').text
    print('访问成功')
except requests.exceptions.RequestException as error:
    print(error)

print(time.strftime('结束时间:%Y-%m-%d %H:%M:%S'))

